
Inventory = {}
Inventory.Items = {}

Inventory.Green = Color(70,250,170,255)
Inventory.Red = Color(250,120,100,255)
Inventory.Blue = Color(70,170,250,255)
Inventory.Yellow = Color(250,220,70,255)
Inventory.White = Color(250,250,250,255)

Inventory.Alert = Sound("npc/dog/dog_disappointed.wav") //playfull4
Inventory.AmmoPickup = Sound("items/ammo_pickup.wav")
Inventory.ItemPickup = Sound("items/itempickup.wav")
Inventory.ItemDrop = Sound("items/ammopickup.wav")
Inventory.Deny = Sound("common/wpn_denyselect.wav")

function Inventory.Notice(ply,text,col)
	if CLIENT then return end
	ply:ClientMsg(text)
	local ntext = string.gsub(text, "%s+", "  ")
	umsg.Start("InventoryNotice", ply)
	umsg.String( ntext )
	umsg.Short( col.r )
	umsg.Short( col.g )
	umsg.Short( col.b )
	umsg.End() 
	if col == Inventory.White then
		ply:ClientSound(Inventory.Alert)
	end
end

function Inventory.MerchantTrace(ply) //obsol33t
	if GameInfo.MerchantTrace then
		return true
	end
	if ply:HasInvItem("models/props/de_prodigy/desk_console1b.mdl") 
	or ply:HasInvItem("models/props/cs_office/phone.mdl") 
	or ply:HasInvItem("models/props/cs_office/phone_p2.mdl") then
		return true
	else
		local trace = util.GetPlayerTrace(ply, Vector(0,0,1) )
		local tr = util.TraceLine(trace) 
		if tr.HitSky then
			return true
		else
			return false
		end
	end
end

function Inventory.PlayerTrace(ply)
	local trace = util.GetPlayerTrace(ply)
	local tr = util.TraceLine(trace) 
	if tr.HitPos:Distance(ply:GetPos()) < 90 then
		if tr.HitWorld then return end
		if tr.Entity.IsDead then return end
		if string.find(tr.Entity:GetClass(),"weapon") then
			if Inventory.WeaponCount(ply) < ply.WeaponSlots then
				for k,v in pairs(ply:GetWeapons()) do
					if v:GetWorldModel() == tr.Entity:GetModel() then
						Inventory.Notice(ply, "You already have that gun", Inventory.Red)
						ply:ClientSound(ChooseRandom(GameSounds.Deny))
						return
					end
				end
				if tr.Entity.Used then
					tr.Entity:Remove()
				else
					ply:Give(tr.Entity:GetWeaponType())
					ply:SelectWeapon(tr.Entity:GetWeaponType())
					Inventory.Notice(ply, "Picked up weapon: "..tr.Entity:GetPrintName(), Inventory.Green)
					tr.Entity.Used = true
					tr.Entity:Remove()
				end
			else
				Inventory.Notice(ply, "You need to drop a gun first", Inventory.Red)
			end
		elseif string.find(tr.Entity:GetClass(),"prop_physic") then
			if ply:CanAddToInventory(tr.Entity:GetModel()) then
				ply:AddAwardPoints(AWARD_GOOD_ITEMS,1)
				if Inventory.CheckItem(ply,tr.Entity) then
					ply:AddToInventory(tr.Entity)
				end
			elseif Inventory.FindTable(tr.Entity:GetModel()) == nil and ply:GetStamina() > 10 then
				local phys = tr.Entity:GetPhysicsObject()
				if phys:IsValid() then
					phys:ApplyForceCenter(ply:GetAimVector() * (phys:GetMass() * 200))
					ply:TakeStamina(15)
				end
			end
		end
	end
end

function Inventory.RemoveEnt(ent,wood)
	ent:SetColor(0,0,0,0)
	ent.IsDead = true
	if wood then
		ent:Fire("break",1,0.25)
	else
		ent:Fire("kill",1,0.25)
	end
end

function Inventory.RemoveDoor(ent)
	Inventory.RemoveEnt(ent)
	if not ent.Gib then
		ent.Gib = true
		local prop = ents.Create("prop_physics_respawnable")
		prop:SetPos(ent:GetPos())
		prop:SetAngles(ent:GetAngles())
		prop:SetModel("models/props_c17/door01_left.mdl")
		prop:SetSkin(ent:GetSkin())
		prop:SetCollisionGroup(COLLISION_GROUP_WEAPON)
		prop:Spawn()
	end
end

function Inventory.PickupEffect(ent)
	if CLIENT then return end
	local effectdata = EffectData()
	effectdata:SetEntity(ent)
	util.Effect("inventory_take", effectdata,true,true)
	local effectdata = EffectData()
	effectdata:SetEntity(ent)
	util.Effect("prop_blue", effectdata,true,true)
end

function Inventory.FindTable(model)
	model = string.lower(model)
	for k,v in pairs(Inventory.Items) do
		if string.find(model,v.Model) then
			return v
		end
	end
	return nil
end

function Inventory.CheckItem(ply,ent) //return false to not add it to the inventory
	local tbl = Inventory.FindTable(ent:GetModel())
	if tbl.Ammo then
		ply:EmitSound(Inventory.AmmoPickup,100,math.random(90,100))
		ply:EmitSound(Inventory.ItemPickup,100,math.random(90,100))
		ply:AddAmmunition(tbl.Ammo,tbl.Functions)
		Inventory.Notice(ply, "Picked up ammo: "..tbl.Name, Inventory.Blue)
		if ent:IsValid() then
			Inventory.PickupEffect(ent)
			Inventory.RemoveEnt(ent)
		end
		return false
	elseif tbl.Points then
		ply:EmitSound(ChooseRandom(GameSounds.Cash),100,math.random(90,100))
		ply:EmitSound(Inventory.ItemPickup,100,math.random(90,100))
		Inventory.Notice(ply, "Picked up some cash", Inventory.Green)
		ply:AddPoints(tbl.Functions)
		if ent:IsValid() then
			Inventory.PickupEffect(ent)
			Inventory.RemoveEnt(ent)
		end
		return false
	elseif tbl.Barricade then
		Inventory.PickupEffect(ent)
		ply:AddToInventory(nil,ChooseRandom(Inventory.WoodParts))
		if ent:IsValid() then
			Inventory.RemoveEnt(ent,true)
		end
		return false
	elseif tbl.Kit then
		if ent.Items == nil then ent.Items = table.Count(tbl.Functions) or 1 end
		if ent.Items <= 0 then Inventory.Notice(ply, "That container is empty", Inventory.Red) ply:ClientSound(Inventory.Deny) return false end
		if ply:GetWeight() == ply:GetInvSlots() then Inventory.Notice(ply, "Your inventory is full", Inventory.Red) ply:ClientSound(Inventory.Deny) return false end
		local item = ChooseRandom(tbl.Kit)
		local itemtbl = Inventory.FindTable(item)
		while (ply:GetWeight() + itemtbl.Weight > ply:GetInvSlots()) do
			item = ChooseRandom(tbl.Kit)
			itemtbl = Inventory.FindTable(item)
		end
		local canhave = ply:CanAddToInventory(item)
		if canhave then	
			local ent2 = ents.Create("prop_physics_respawnable")
			ent2:SetModel(item)
			ent2:SetPos(ent:GetPos() + Vector(0,0,5))
			ent2:Spawn()
			ent2:SetColor(0,0,0,0)
			ent2:SetHealth(150)
			if Inventory.CheckItem(ply,ent2) then
				ply:AddToInventory(ent2)
			end
			Inventory.PickupEffect(ent)
			ent.Items = ent.Items - 1
		end
		return false
	elseif tbl.AmmoKit then
		if ent.Items == nil then ent.Items = table.Count(tbl.Functions) or 1 end
		if ent.Items <= 0 then Inventory.Notice(ply, "That container is empty", Inventory.Red) ply:ClientSound(Inventory.Deny) return false end
		//if ply:GetWeight() == ply:GetInvSlots() then Inventory.Notice(ply, "Your inventory is full", Inventory.Red) ply:ClientSound(Inventory.Deny) return false end
		if ent.Users == nil then
			ent.Users = {ply}
		else
			if table.HasValue(ent.Users,ply) then
				Inventory.Notice(ply, "That container is empty", Inventory.Red)
				ply:ClientSound(Inventory.Deny)
				return false
			end
		end
		if not ent.Types then
			ent.Types = {}
			ent.Types["pistol"] = {Amt=40, Name="Pistol Rounds"}
			ent.Types["smg1"] = {Amt=60, Name="SMG Rounds"}
			ent.Types["buckshot"] = {Amt=12, Name="Buckshot"}
			ent.Types["ar2"] = {Amt=30, Name="Rifle Rounds"}
		end
		local wep = ply:GetActiveWeapon()
		local atype = wep:GetUsedAmmoType()
		if ent.Types[atype] then
			Inventory.Notice(ply, "Picked up ammo: "..ent.Types[atype].Name, Inventory.Blue)
			ply:AddAmmunition(atype,ent.Types[atype].Amt)
			ply:EmitSound(Inventory.AmmoPickup,100,math.random(90,100))
			Inventory.PickupEffect(ent)
			ent.Items = ent.Items - 1
			table.insert(ent.Users,ply)
		else
			Inventory.Notice(ply, "You aren't holding a weapon", Inventory.Red)
			ply:ClientSound(Inventory.Deny)
		end
		return false
	end
	Inventory.PickupEffect(ent)
	return true
end

function Inventory.WeaponCount(ply)
	local types = {"smg1","buckshot","pistol","ar2"}
	local count = 0
	for k,v in pairs(ply:GetWeapons()) do
		if table.HasValue(types,v:GetUsedAmmoType()) then
			count = count + 1
		end
	end
	return count
end

function Inventory.Eat(ply,item,readin)
	if readin then return "Eat" end
	ply:RemoveFromInventory(item)
	ply:AddHealth(5)
	ply:VoiceSound(ChooseRandom(ply.Pickup),100,.5) 
	ply:EmitSound(Sound(ChooseRandom(GameSounds.Food)),100,math.random(90,110))
	local tbl = Inventory.FindTable(item)
	Inventory.Notice(ply, "Gained 5 HP", Inventory.Blue)
end

function Inventory.Drink(ply,item,readin)
	if readin then return "Drink" end
	ply:RemoveFromInventory(item)
	ply:AddHealth(5)
	ply:VoiceSound(ChooseRandom(ply.Pickup),100,.5) 
	ply:EmitSound(Sound(ChooseRandom(GameSounds.Beer)),100,math.random(90,110))
	local tbl = Inventory.FindTable(item)
	Inventory.Notice(ply, "Gained 5 HP", Inventory.Blue)
end

function Inventory.DrinkB(ply,item,readin)
	if readin then return "Drink" end
	ply:RemoveFromInventory(item)
	if ply:HasInvItem("models/props_junk/metalgascan.mdl") or ply:HasInvItem("models/props_junk/gascan001a.mdl") then
		ply:AddToInventory(nil,"models/props/cs_militia/bottle02.mdl") //molotov
	else
		ply:AddToInventory(nil,"models/props/cs_militia/bottle01.mdl") //bottle
	end
	ply:AddHealth(5)
	ply:VoiceSound(ChooseRandom(ply.Pickup),100,.5) 
	ply:EmitSound(Sound(ChooseRandom(GameSounds.Beer)),100,math.random(90,110))
	Inventory.Notice(ply, "Gained 5 HP", Inventory.Blue)
end

function Inventory.DrinkC(ply,item,readin)
	if readin then return "Drink" end
	ply:RemoveFromInventory(item)
	local tbl = Inventory.FindTable(item)
	Inventory.Notice(ply, "Gained 5 HP", Inventory.Blue)
	Inventory.Notice(ply, "Restored stamina", Inventory.Blue)
	ply:AddHealth(5)
	ply:AddStamina(100)
	ply:VoiceSound(ChooseRandom(ply.Pickup),100,.5) 
	ply:EmitSound(Sound(ChooseRandom(GameSounds.Beer)),100,math.random(90,110))
end

function Inventory.FillUp(ply,item,readin)
	if readin then return "Add Gas" end
	local inv = ply:GetInventory()
	local gas = false
	for k,v in pairs(inv) do
		if v == "models/props_junk/metalgascan.mdl" or v == "models/props_junk/gascan001a.mdl" then
			gas = true
		end
	end
	if gas then
		ply:RemoveFromInventory(item)
		ply:AddToInventory(nil,"models/props/cs_militia/bottle02.mdl")
		ply:EmitSound(Sound(ChooseRandom(GameSounds.Beer)),100,math.random(90,110))
		//Inventory.Notice(ply, "Created a molotov", Inventory.Green)
	else
		Inventory.Notice(ply, "You need gasoline", Inventory.Red)
	end
end

function Inventory.Aid(ply,item,readin)
	if readin then return "Use" end
	ply:RemoveFromInventory(item)
	local tbl = Inventory.FindTable(item)
	Inventory.Notice(ply, "Gained 10 HP", Inventory.Blue)
	Inventory.Notice(ply, "Stopped all bleeding", Inventory.Blue)
	ply:AddHealth(10)
	ply:StopBleeding()
	ply:VoiceSound(ChooseRandom(ply.Pickup),100,.5) 
	ply:EmitSound(Sound(ChooseRandom(GameSounds.HealthVial)),100,math.random(90,110))
end

function Inventory.Antidote(ply,item,readin)
	if readin then return "Use" end
	ply:RemoveFromInventory(item)
	ply:StopPoison()
	ply:AddStamina(50)
	ply:VoiceSound(ChooseRandom(ply.Pickup),100,.5) 
	ply:EmitSound(ChooseRandom(GameSounds.HealthVial),100,100)
	local tbl = Inventory.FindTable(item)
	Inventory.Notice(ply, "Restored some stamina", Inventory.Blue)
	umsg.Start("HealthTiny", ply)
	umsg.End() 
	Inventory.Notice(ply, "Neutralized all toxins", Inventory.Blue)
	ply:StopInfection()
	ply:StopPoison()
	ply:StopBlindness()
end

function Inventory.HealthVial(ply,item,readin)
	if readin then return "Use" end
	ply:RemoveFromInventory(item)
	ply:AddHealth(25)
	ply:AddStamina(100)
	ply:StopBlindness()
	ply:VoiceSound(ChooseRandom(ply.Pickup),100,.5) 
	ply:EmitSound(ChooseRandom(GameSounds.HealthVial),100,100)
	local tbl = Inventory.FindTable(item)
	Inventory.Notice(ply, "Gained 25 HP", Inventory.Blue)
	Inventory.Notice(ply, "Restored stamina", Inventory.Blue)
end

function Inventory.HealthKit(ply,item,readin)
	if readin then return "Use" end
	ply:RemoveFromInventory(item)
	ply:AddHealth(50)
	ply:AddStamina(50)
	ply:StopBleeding()
	ply:VoiceSound(ChooseRandom(ply.Pickup),100,.5) 
	ply:EmitSound(ChooseRandom(GameSounds.HealthKit),100,100)
	local tbl = Inventory.FindTable(item)
	Inventory.Notice(ply, "Gained 50 HP", Inventory.Blue)
	Inventory.Notice(ply, "Stopped all bleeding", Inventory.Blue)
	Inventory.Notice(ply, "Restored some stamina", Inventory.Blue)
	Inventory.Notice(ply, "Neutralized all toxins", Inventory.Blue)
	ply:StopInfection()
	ply:StopPoison()
	ply:StopBlindness()
end

function Inventory.BadEat(ply,item,readin)
	if readin then return "Eat" end
	ply:RemoveFromInventory(item)
	if ply.HumanClass != "Militant" then
		ply:TakeHealth(10)
		if math.random(1,4) == 1 then
			ply:DoBleed()
		end
		umsg.Start("HealthLoss", ply)
		umsg.End() 
		ply:VoiceSound(ChooseRandom(ply.Cough),100,.5) 
		ply:EmitSound(Sound(ChooseRandom(GameSounds.Food)),100,math.random(90,110))
		local tbl = Inventory.FindTable(item)
		local name = string.lower(tbl.Name)
		Inventory.Notice(ply, "You just ate a fucking "..name.."!", Inventory.Red)
	else
		ply:AddHealth(5)
		ply:VoiceSound(ChooseRandom(ply.Pickup),100,.5) 
		ply:EmitSound(Sound(ChooseRandom(GameSounds.Food)),100,math.random(90,110))
		local tbl = Inventory.FindTable(item)
		Inventory.Notice(ply, "Gained 5 HP", Inventory.Blue)
	end
end

function Inventory.BadDrink(ply,item,readin)
	if readin then return "Drink" end
	ply:RemoveFromInventory(item)
	if ply.HumanClass != "Militant" then
		ply:TakeHealth(5)
		if math.random(1,4) == 1 then
			ply:DoBlind()
		end
		umsg.Start("HealthLoss", ply)
		umsg.End() 
		ply:VoiceSound(ChooseRandom(ply.Cough),100,.5) 
		ply:EmitSound(Sound(ChooseRandom(GameSounds.Beer)),100,math.random(90,110))
		local tbl = Inventory.FindTable(item)
		local name = string.lower(tbl.Name)
		Inventory.Notice(ply, "You just drank "..name.."!", Inventory.Red)
	else
		ply:AddHealth(5)
		ply:VoiceSound(ChooseRandom(ply.Pickup),100,.5) 
		ply:EmitSound(Sound(ChooseRandom(GameSounds.Beer)),100,math.random(90,110))
		local tbl = Inventory.FindTable(item)
		Inventory.Notice(ply, "Gained 5 HP", Inventory.Blue)
	end
end

function Inventory.CallMerchant(ply,item,readin)
	if readin then return "Use" end
	ply:ConCommand("gm_showspare1")
end

function Inventory.Read(ply,item,readin)
	if readin then return "Read" end
	ply:ConCommand("gm_showhelp")
end

function Inventory.Give(ply,model,readin)
	if readin then return "Give" end
	local trace = util.GetPlayerTrace(ply)
	local tr = util.TraceLine(trace) 
	if tr.Entity:IsPlayer() then
		if tr.HitPos:Distance(ply:GetPos()) > 100 then
			Inventory.Notice(ply, "You are too far away", Inventory.Red)
			return
		end
		if tr.Entity:Team() == ply:Team() then
			local canhave = tr.Entity:CanAddToInventory(model)
			if canhave then
				Inventory.Notice(ply, "You gave away an item", Inventory.Green)
				tr.Entity:AddToInventory(nil,model)
				ply:RemoveFromInventory(model)
				ply:EmitSound(Inventory.ItemDrop,100,math.random(95,105))
			else
				Inventory.Notice(ply, "That person can't hold this item.", Inventory.Red)
				ply:ClientSound(Inventory.Deny)
			end
		end
	else
		Inventory.Notice(ply, "You need to face a person", Inventory.Red)
		ply:ClientSound(Inventory.Deny)
	end
end

function Inventory.Drop(ply,model,readin)
	if readin then return "Drop" end
	ply:RemoveFromInventory(model)
	ply:EmitSound(Inventory.ItemDrop,100,math.random(95,105))
	local pos = ply:GetPos() + Vector(0,0,45) + (ply:GetForward() * 40)
	local item = ents.Create("prop_physics_respawnable")
	item:SetModel(model)
	item:SetKeyValue("RespawnTime","80")
	if util.IsInWorld(pos) then
		item:SetPos(pos)
	else
		item:SetPos(ply:GetPos() + Vector(0,0,20))
	end
	item:Spawn()
	item:SetHealth(150)
end

function Inventory.DropWeapon(ply,model,readin) //todo: giveweapon
	if readin then return "Drop" end
	local tbl = Inventory.FindWeaponTable(model)
	ply:StripWeapon(tbl.Weapon)
	ply:EmitSound(Inventory.ItemDrop,100,math.random(95,105))
	local pos = ply:GetPos() + Vector(0,0,45) + (ply:GetForward() * 40)
	local item = ents.Create("sent_weapon")
	util.PrecacheModel(model)
	item:SetModel(model)
	item:SetPos(ply:GetPos() + Vector(0,0,30))
	item:SetAngles(ply:GetRight():Angle())
	item:Spawn()
	if util.IsInWorld(pos) then
		item:SetPos(pos)
	else
		item:SetPos(ply:GetPos() + Vector(0,0,30))
	end
	ply:SynchInventory()
end

function Inventory.Loot(ply,model,readin)
	if readin then return "Loot" end
	ply:RemoveFromInventory(model)
	if math.random(1,5) == 1 then
		Inventory.Notice(ply, "You found some cash", Inventory.Green)
		ply:EmitSound(ChooseRandom(GameSounds.Cash),100,math.random(95,105))
		ply:AddPoints(math.random(2,5))
	else
		Inventory.Notice(ply, "This register is empty", Inventory.Red)
		ply:EmitSound(Inventory.ItemDrop,100,math.random(95,105))
	end
end

Inventory.Bibsound = Sound("ambient/levels/labs/teleport_mechanism_windup4.wav")
Inventory.Bibrant = Sound("vo/ravenholm/monk_rant15.wav")
function Inventory.Bible(ply,model,readin)
	if readin then return "Recite" end
	ply:RemoveFromInventory(model)
	for k,v in pairs(player.GetAll()) do
		if v:GetPos():Distance(ply:GetPos()) < 400 then
			if v:Team() == TEAM_UNDEAD then
				v:DoIgnite(ply)
				Inventory.Notice(v,"The power of Christ compels you!",Inventory.Red)
			else
				v:AddStamina(50)
				v:StopBleeding()
				Inventory.Notice(v, "Neutralized all toxins", Inventory.Blue)
				v:StopInfection()
				v:StopPoison()
				v:StopBlindness()
				Inventory.Notice(v, "Stopped all bleeding", Inventory.Blue)
				Inventory.Notice(v, "Restored some stamina", Inventory.Blue)
				Inventory.Notice(v, "You have been blessed", Inventory.Blue)
				v:ClientSound(Inventory.Bibsound)
				local effectdata = EffectData()
				effectdata:SetEntity(v)
				effectdata:SetOrigin(v:GetPos())
				util.Effect("holy_aura", effectdata, true)
				if v == ply then
					v:VoiceSound(Inventory.Bibrant,100,.1)
				end
			end
		end
	end
	for k,v in pairs(ents.FindByClass("npc_*")) do
		if v:GetPos():Distance(ply:GetPos()) < 400 then
			v:NpcIgnite(ply)
		end
	end
end

function Inventory.Throw(ply,model,readin)
	if readin then return "Throw" end
	ply:RemoveFromInventory(model)
	ply:EmitSound(ChooseRandom(GameSounds.Throw),100,math.random(95,105))
	local item = ents.Create("prop_physics_respawnable")
	item:SetModel(model)
	item:SetKeyValue("RespawnTime","80")
	item:SetPos(ply:GetPos() + Vector(0,0,50) + (ply:GetForward() * 40))
	item:Spawn()
	local phys = item:GetPhysicsObject()
	if phys:IsValid() then
		phys:ApplyForceCenter(ply:GetAimVector() * 6000)
	end
	item:SetHealth(150)
end

function Inventory.ThrowGas(ply,model,readin)
	if readin then return "Throw" end
	ply:RemoveFromInventory(model)
	ply:EmitSound(ChooseRandom(GameSounds.Throw),100,math.random(95,105))
	local item = ents.Create("bomb_gas")
	item:SetPos(ply:GetPos() + Vector(0,0,55) + (ply:GetForward() * 40))
	item:SetModel(model)
	item:Spawn()
	item:SetPwner(ply)
	local phys = item:GetPhysicsObject()
	if phys:IsValid() then
		phys:SetVelocity(ply:GetForward() * 800)
	end
end

function Inventory.DrinkGas(ply,model,readin)
	if readin then return "Drink" end
	ply:RemoveFromInventory(model)
	ply:VoiceSound(ChooseRandom(ply.Pain),100,.5) 
	ply:EmitSound(Sound("ambient/fire/mtov_flame2.wav"),100,math.random(90,110))
	ply:DoIgnite()
	Inventory.Notice(ply, "You drank gasoline!", Inventory.Red)
end

function Inventory.ThrowPropane(ply,model,readin)
	if readin then return "Throw" end
	ply:RemoveFromInventory(model)
	ply:EmitSound(ChooseRandom(GameSounds.Throw),100,math.random(95,105))
	local item = ents.Create("bomb_propane")
	item:SetPos(ply:GetPos() + Vector(0,0,55) + (ply:GetForward() * 40))
	item:SetModel(model)
	item:Spawn()
	item:SetPwner(ply)
	local phys = item:GetPhysicsObject()
	if phys:IsValid() then
		phys:SetVelocity(ply:GetForward() * 800)
	end
end

function Inventory.ThrowExt(ply,model,readin)
	if readin then return "Throw" end
	ply:RemoveFromInventory(model)
	ply:EmitSound(ChooseRandom(GameSounds.Throw),100,math.random(95,105))
	local item = ents.Create("bomb_extinguish")
	item:SetModel(model)
	item:SetPos(ply:GetPos() + Vector(0,0,55) + (ply:GetForward() * 40))
	item:Spawn()
	local phys = item:GetPhysicsObject()
	if phys:IsValid() then
		phys:SetVelocity(ply:GetForward() * 800)
	end
end

function Inventory.ThrowMolotov(ply,model,readin)
	if readin then return "Throw" end
	ply:RemoveFromInventory(model)
	ply:EmitSound(ChooseRandom(GameSounds.Throw),100,math.random(95,105))
	local item = ents.Create("bomb_molotov")
	item:SetPos(ply:GetPos() + Vector(0,0,55) + (ply:GetForward() * 40))
	item:Spawn()
	item:SetOwner(ply)
	local phys = item:GetPhysicsObject()
	if phys:IsValid() then
		phys:SetVelocity(ply:GetForward() * 800)
	end
end

function Inventory.AddToList(lolwut,tbl)
	local num = table.Count(Inventory.Items) + 1
	Inventory.Items[num] = tbl
	util.PrecacheModel(tbl.Model or "models/props_junk/glassbottle01a.mdl")
end

Inventory.MysteryItems = {"models/props/cs_militia/bottle02.mdl", //lol gambling
"models/props/cs_militia/bottle02.mdl",
"models/items/battery.mdl",
"models/healthvial.mdl",
"models/Items/357ammobox.mdl",
"models/Items/boxsrounds.mdl",
"models/props_lab/box01b.mdl",
"models/props_lab/bindergraylabel01a.mdl",
"models/items/combine_rifle_cartridge01.mdl",
"models/props_junk/garbage_bag001a.mdl",
"models/props/cs_office/coffee_mug2.mdl",
"models/props/cs_office/coffee_mug3.mdl",
"models/props_junk/popcan01a.mdl",
"models/gibs/hgibs_spine.mdl",
"models/props_c17/trappropeller_lever.mdl",
"models/gibs/hgibs.mdl",
"models/props_lab/jar01a.mdl",
"models/props/cs_italy/bananna.mdl",
"models/props/cs_italy/orange.mdl",
"models/props/de_prodigy/desk_console1b.mdl",
"models/props/cs_office/radio.mdl",
"models/props/cs_office/snowman_hat.mdl",
"models/props/de_tides/vending_hat.mdl",
"models/props/de_tides/vending_turtle.mdl",
"models/props_junk/garbage_newspaper001a.mdl",
"models/props_lab/bindergreenlabel.mdl",
"models/props_junk/shoe001a.mdl",
"models/props_c17/tools_wrench01a.mdl"}

Inventory.KitItems = {"models/props_junk/glassbottle01a.mdl", //these come from boxes
"models/props_junk/popcan01a.mdl",
"models/props_junk/garbage_milkcarton001a.mdl",
"models/props_junk/garbage_milkcarton002a.mdl",
"models/props/cs_office/trash_can_p7.mdl",
"models/props/cs_office/trash_can_p8.mdl",
"models/props/cs_office/paper_towels.mdl",
"models/props/cs_office/cardboard_box02.mdl",
"models/props/cs_office/snowman_hat.mdl",
"models/props_lab/huladoll.mdl",
"models/props/cs_assault/money.mdl",
"models/props/cs_assault/dollar.mdl",
"models/props/de_tides/vending_hat.mdl",
"models/props/de_tides/vending_turtle.mdl",
"models/props/cs_office/snowman_face.mdl",
"models/props_lab/jar01a.mdl",
"models/props_lab/cactus.mdl",
"models/props_c17/metalpot002a.mdl",
"models/props_interiors/pot01a.mdl",
"models/props_junk/garbage_takeoutcarton001a.mdl",
"models/props_junk/shoe001a.mdl",
"models/props_c17/paper01.mdl",
"models/Gibs/HGIBS_spine.mdl",
"models/props_c17/trappropeller_lever.mdl",
"models/items/battery.mdl",
"models/items/battery.mdl",
"models/healthvial.mdl",
"models/healthvial.mdl",
"models/items/healthkit.mdl",
"models/Items/357ammobox.mdl",
"models/items/boxmrounds.mdl",
"models/items/boxsrounds.mdl",
"models/items/boxbuckshot.mdl",
"models/props/cs_militia/bottle02.mdl",
"models/items/combine_rifle_cartridge01.mdl",
"models/props_debris/wood_chunk06b.mdl",
"models/props/cs_militia/bottle01.mdl",
"models/props/cs_militia/bottle03.mdl",
"models/props/cs_militia/bottle03.mdl",
"models/props/cs_italy/orange.mdl",
"models/props/cs_militia/fishriver01.mdl",
"models/props_junk/cardboard_box004a.mdl",
"models/props_lab/box01b.mdl",
"models/props/cs_office/water_bottle.mdl",
"models/props/cs_italy/bananna.mdl",
"models/props/cs_italy/bananna_bunch.mdl",
"models/props_junk/garbage_metalcan001a.mdl",
"models/props_junk/garbage_metalcan002a.mdl",
"models/props_junk/garbage_plasticbottle002a.mdl",
"models/props_junk/garbage_plasticbottle003a.mdl",
"models/props_junk/glassbottle01a.mdl",
"models/props_junk/garbage_glassbottle001a.mdl",
"models/props_junk/garbage_glassbottle002a.mdl",
"models/props_junk/garbage_glassbottle003a.mdl",
"models/props/cs_office/coffee_mug2.mdl",
"models/props/cs_office/coffee_mug3.mdl",
"models/props/de_inferno/crate_fruit_break_gib2.mdl",
"models/props_junk/watermelon01.mdl",
"models/props_c17/pottery01a.mdl",
"models/props_c17/pottery04a.mdl",
"models/props_lab/reciever01d.mdl",
"models/props_lab/reciever01c.mdl",
"models/props_lab/reciever01a.mdl",
"models/props_junk/terracotta01.mdl",
"models/props_c17/tools_wrench01a.mdl",
"models/props_c17/tools_pliers01a.mdl",
"models/props_c17/lamp001a.mdl",
"models/props_lab/clipboard.mdl",
"models/props_lab/bindergreenlabel.mdl",
"models/props_lab/bindergraylabel01a.mdl",
"models/props_lab/binderredlabel.mdl",
"models/props_lab/binderblue.mdl",
"models/props/cs_office/computer_keyboard.mdl",
"models/props/cs_office/radio.mdl",
"models/props/cs_office/fire_extinguisher.mdl",
"models/props/de_prodigy/desk_console1b.mdl",
"models/props_junk/garbage_newspaper001a.mdl",
"models/props_c17/paper01.mdl",
"models/props_junk/rock001a.mdl",
"models/props_junk/cinderblock01a.mdl",
"models/gibs/hgibs.mdl",
"models/props_wasteland/gear02.mdl",
"models/props_wasteland/prison_padlock001b.mdl",
"models/props_combine/breenglobe.mdl",
"models/items/car_battery01.mdl",
"models/props_lab/desklamp01.mdl",
"models/props_junk/garbage_bag001a.mdl"}

Inventory.AmmoItems = {"models/items/357ammobox.mdl", //obsolete?
"models/items/357ammobox.mdl",
"models/items/boxmrounds.mdl",
"models/items/boxsrounds.mdl",
"models/items/boxbuckshot.mdl"}

Inventory.AidItems = {"models/props/cs_office/paper_towels.mdl",
"models/props_lab/box01b.mdl",
"models/props/cs_assault/dollar.mdl",
"models/items/357ammo.mdl",
"models/Items/BoxMRounds.mdl",
"models/Items/BoxSRounds.mdl",
"models/Items/BoxBuckshot.mdl",
"models/items/battery.mdl",
"models/healthvial.mdl",
"models/items/healthkit.mdl"}

Inventory.WoodParts = {"models/props_debris/wood_chunk04a.mdl",
"models/props_debris/wood_chunk06b.mdl",
"models/props_debris/wood_chunk06a.mdl"}

Inventory.ZombieItems = {"models/props_junk/PopCan01a.mdl", //these are held by npc zombies
"models/props/cs_assault/money.mdl",
"models/props/cs_assault/dollar.mdl",
"models/props/cs_assault/dollar.mdl",
"models/props_lab/box01a.mdl",
"models/items/battery.mdl",
"models/items/357ammo.mdl",
"models/props/cs_office/phone_p2.mdl",
"models/props/de_prodigy/desk_console1b.mdl",
"models/props_lab/binderredlabel.mdl",
"models/props_lab/bindergraylabel01a.mdl",
"models/props/cs_office/water_bottle.mdl",
"models/props_junk/garbage_metalcan001a.mdl",
"models/props_junk/garbage_metalcan002a.mdl",
"models/props_junk/garbage_takeoutcarton001a.mdl",
"models/props_junk/garbage_coffeemug001a.mdl", 
"models/props/cs_office/coffee_mug2.mdl",
"models/props/cs_office/coffee_mug3.mdl",
"models/props/cs_militia/bottle03.mdl",
"models/props/de_inferno/crate_fruit_break_gib2.mdl",
"models/props/cs_italy/orange.mdl",
"models/props/cs_italy/bananna.mdl",
"models/props/cs_office/trash_can_p7.mdl",
"models/props/cs_office/trash_can_p8.mdl",
"models/props_junk/glassbottle01a.mdl",
"models/props_c17/trappropeller_lever.mdl",
"models/props_lab/bindergreenlabel.mdl",
"models/props_lab/binderbluelabel.mdl",
"models/props_lab/clipboard.mdl",
"models/props_wasteland/prison_padlock001a.mdl",
"models/props_c17/tools_wrench01a.mdl",
"models/props_c17/tools_pliers01a.mdl",
"models/props_c17/tools_pliers01a.mdl",
"models/props_junk/shoe001a.mdl"}

FOOD="Food"
DRINK="Drink"
WOOD="Wood Source"
WOODC="Wood Chunk"
AID="Bandages"
KIT="Supplies"
KIT2="Box"
KIT3="Ammo Crate"

Inventory.AddToList(11,{Name=DRINK, Weight=1, Model="models/props_junk/glassbottle01a.mdl", Functions={Inventory.DrinkB}})
Inventory.AddToList(11,{Name="Milk", Weight=2, Model="models/props_junk/garbage_milkcarton001a.mdl", Functions={Inventory.Drink}})
Inventory.AddToList(21,{Name="Milk", Weight=1, Model="models/props_junk/garbage_milkcarton002a.mdl", Functions={Inventory.Drink}})
Inventory.AddToList(31,{Name=DRINK, Weight=1, Model="models/props_junk/garbage_plasticbottle003a.mdl", Functions={Inventory.Drink}})
Inventory.AddToList(41,{Name="Cold Tea", Weight=1, Model="models/props_interiors/pot01a.mdl", Functions={Inventory.Drink}})
Inventory.AddToList(51,{Name="Coffee", Weight=1, Model="models/props_junk/garbage_coffeemug001a.mdl", Functions={Inventory.DrinkC}})
Inventory.AddToList(81,{Name="Empty Bottle", Weight=1, Model="models/props/cs_militia/bottle01.mdl", Functions={Inventory.FillUp}})
Inventory.AddToList(71,{Name=DRINK, Weight=1, Model="models/props_junk/garbage_glassbottle002a.mdl", Functions={Inventory.DrinkB}})
Inventory.AddToList(81,{Name=DRINK, Weight=1, Model="models/props_junk/garbage_glassbottle003a.mdl", Functions={Inventory.DrinkB}})
Inventory.AddToList(91,{Name=FOOD, Weight=1, Model="models/props_junk/garbage_metalcan001a.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(10,{Name=FOOD, Weight=1, Model="models/props_junk/garbage_metalcan002a.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(14,{Name=FOOD, Weight=1, Model="models/props_junk/garbage_takeoutcarton001a.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(17,{Name="Baby", Weight=1, Model="models/props_c17/doll01.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(15,{Name=DRINK, Weight=1, Model="models/props_junk/glassjug01.mdl", Functions={Inventory.Drink}})
Inventory.AddToList(52,{Name=DRINK, Weight=1, Model="models/props/cs_office/water_bottle.mdl", Functions={Inventory.Drink}})
Inventory.AddToList(18,{Name="Soda", Weight=1, Model="models/props_junk/popcan01a.mdl", Functions={Inventory.DrinkC}})
Inventory.AddToList(52,{Name="Soda", Weight=1, Model="models/props/cs_office/trash_can_p7.mdl", Functions={Inventory.DrinkC}})
Inventory.AddToList(52,{Name="Soda", Weight=1, Model="models/props/cs_office/trash_can_p8.mdl", Functions={Inventory.DrinkC}})
Inventory.AddToList(19,{Name="Shoe", Weight=1, Model="models/props_junk/shoe001a.mdl", Functions={Inventory.BadEat,Inventory.Throw}})
Inventory.AddToList(20,{Name="Melon", Weight=2, Model="models/props_junk/watermelon01.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(73,{Name="Wine", Weight=2, Model="models/props_c17/pottery04a.mdl", Functions={Inventory.DrinkC}}) 
Inventory.AddToList(72,{Name="Soup", Weight=1, Model="models/props_c17/pottery01a.mdl", Functions={Inventory.DrinkC}}) 
Inventory.AddToList(22,{Name="Soup", Weight=2, Model="models/props_c17/metalpot001a.mdl", Functions={Inventory.Drink}})
Inventory.AddToList(23,{Name="Bacon", Weight=1, Model="models/props_c17/metalpot002a.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(24,{Name="Soup", Weight=1, Model="models/props_interiors/pot02a.mdl", Functions={Inventory.Drink}})
Inventory.AddToList(28,{Name=FOOD, Weight=1, Model="models/props_lab/jar01a.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(29,{Name=FOOD, Weight=2, Model="models/props_lab/jar01b.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(71,{Name=FOOD, Weight=1, Model="models/props_junk/garbage_bag001a.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(49,{Name="Mr. Snowman", Weight=3, Model="models/props/cs_office/snowman_face.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(30,{Name="Tiny Person", Weight=1, Model="models/props_lab/huladoll.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(35,{Name="Banana", Weight=1, Model="models/props/cs_italy/bananna.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(36,{Name="Bananas", Weight=2, Model="models/props/cs_italy/bananna_bunch.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(37,{Name="Orange", Weight=1, Model="models/props/cs_italy/orange.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(37,{Name="Grapefruit", Weight=1, Model="models/props/de_inferno/crate_fruit_break_gib2.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(37,{Name="Fish", Weight=1, Model="models/props/cs_militia/fishriver01.mdl", Functions={Inventory.Eat}})
Inventory.AddToList(39,{Name=DRINK, Weight=1, Model="models/props_junk/garbage_glassbottle001a.mdl", Functions={Inventory.DrinkB}})
Inventory.AddToList(40,{Name=DRINK, Weight=1, Model="models/props/cs_militia/bottle03.mdl", Functions={Inventory.DrinkB}})
Inventory.AddToList(41,{Name="Beer Case", Weight=5, Model="models/props/cs_militia/caseofbeer01.mdl", Functions={Inventory.DrinkB}})
Inventory.AddToList(42,{Name="Coffee", Weight=1, Model="models/props/cs_office/coffee_mug.mdl", Functions={Inventory.DrinkC}})
Inventory.AddToList(43,{Name="Coffee", Weight=1, Model="models/props/cs_office/coffee_mug2.mdl", Functions={Inventory.DrinkC}})
Inventory.AddToList(44,{Name="Coffee", Weight=1, Model="models/props/cs_office/coffee_mug3.mdl", Functions={Inventory.DrinkC}})
Inventory.AddToList(70,{Name=AID, Weight=1, Model="models/props_junk/cardboard_box004a.mdl", Functions={Inventory.Aid}})
Inventory.AddToList(70,{Name=AID, Weight=2, Model="models/props/cs_office/cardboard_box02.mdl", Functions={Inventory.Aid}})
Inventory.AddToList(70,{Name=AID, Weight=2, Model="models/props/cs_office/paper_towels.mdl", Functions={Inventory.Aid}})
Inventory.AddToList(25,{Name=AID, Weight=1, Model="models/props_lab/box01a.mdl", Functions={Inventory.Aid}})
Inventory.AddToList(26,{Name=AID, Weight=1, Model="models/props_lab/box01b.mdl", Functions={Inventory.Aid}})
Inventory.AddToList(32,{Name="Antidote", Weight=1, Model="models/items/battery.mdl", Functions={Inventory.Antidote}})
Inventory.AddToList(33,{Name="Health Vial", Weight=1, Model="models/healthvial.mdl", Functions={Inventory.HealthVial}})
Inventory.AddToList(34,{Name="Health Kit", Weight=2, Model="models/items/healthkit.mdl", Functions={Inventory.HealthKit}})
Inventory.AddToList(62,{Name="Molotov", Weight=1, Model="models/props/cs_militia/bottle02.mdl", Functions={Inventory.ThrowMolotov}})
Inventory.AddToList(22,{Name="Bible", Weight=1, Model="models/props_lab/bindergraylabel01a.mdl", Functions={Inventory.Bible}})
Inventory.AddToList(22,{Name="Respirator", Weight=1, Model="models/items/combine_rifle_cartridge01.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(65,{Name=KIT, Weight=1, Model="models/props_c17/suitcase001a.mdl", Functions={1,1}, Kit=Inventory.KitItems})
Inventory.AddToList(21,{Name=KIT, Weight=1, Model="models/props_c17/briefcase001a.mdl", Functions={1,1}, Kit=Inventory.KitItems})
Inventory.AddToList(69,{Name=KIT2, Weight=1, Model="models/props_junk/cardboard_box001a.mdl", Functions={1,1,1}, Kit=Inventory.KitItems})
Inventory.AddToList(70,{Name=KIT2, Weight=1, Model="models/props_junk/cardboard_box001b.mdl", Functions={1,1,1}, Kit=Inventory.KitItems})
Inventory.AddToList(70,{Name=KIT2, Weight=1, Model="models/props_junk/cardboard_box002a.mdl", Functions={1,1,1}, Kit=Inventory.KitItems})
Inventory.AddToList(70,{Name=KIT2, Weight=1, Model="models/props_junk/cardboard_box002b.mdl", Functions={1,1,1}, Kit=Inventory.KitItems})
Inventory.AddToList(70,{Name=KIT2, Weight=1, Model="models/props_junk/cardboard_box003a.mdl", Functions={1,1}, Kit=Inventory.KitItems})
Inventory.AddToList(70,{Name=KIT2, Weight=1, Model="models/props_junk/cardboard_box003b.mdl", Functions={1,1}, Kit=Inventory.KitItems})
Inventory.AddToList(70,{Name=KIT2, Weight=1, Model="models/props/cs_office/cardboard_box03.mdl", Functions={1,1}, Kit=Inventory.KitItems})
Inventory.AddToList(70,{Name=KIT2, Weight=1, Model="models/props/cs_office/cardboard_box01.mdl", Functions={1,1}, Kit=Inventory.KitItems})
Inventory.AddToList(70,{Name=KIT3, Weight=0, Model="models/items/item_item_crate.mdl", Functions={1,1,1,1,1}, AmmoKit=Inventory.AmmoItems})
Inventory.AddToList(14,{Name="Rifle Rounds", Weight=0, Model="models/items/boxmrounds.mdl", Functions=60, Ammo="ar2"})
Inventory.AddToList(15,{Name="SMG Rounds", Weight=0, Model="models/items/boxsrounds.mdl", Functions=60, Ammo="smg1"})
Inventory.AddToList(16,{Name="Buckshot", Weight=0, Model="models/items/boxbuckshot.mdl", Functions=12, Ammo="buckshot"})
Inventory.AddToList(17,{Name="Pistol Rounds", Weight=0, Model="models/items/357ammobox.mdl", Functions=40, Ammo="pistol"})
Inventory.AddToList(18,{Name="Pistol Rounds", Weight=0, Model="models/items/357ammo.mdl", Functions=40, Ammo="pistol"})
Inventory.AddToList(72,{Name="Gasoline", Weight=6, Model="models/props_junk/gascan001a.mdl", Functions={Inventory.ThrowGas,Inventory.DrinkGas}})
Inventory.AddToList(73,{Name="Gasoline", Weight=6, Model="models/props_junk/metalgascan.mdl", Functions={Inventory.ThrowGas,Inventory.DrinkGas}})
Inventory.AddToList(74,{Name="Propane", Weight=6, Model="models/props_junk/propane_tank001a.mdl", Functions={Inventory.ThrowPropane}})
Inventory.AddToList(75,{Name="Propane", Weight=6, Model="models/props_junk/propanecanister001a.mdl", Functions={Inventory.ThrowPropane}})
Inventory.AddToList(45,{Name="Phone", Weight=1, Model="models/props/cs_office/phone_p2.mdl", Functions={Inventory.CallMerchant}})
Inventory.AddToList(45,{Name="Phone", Weight=1, Model="models/props/cs_office/phone.mdl", Functions={Inventory.CallMerchant}})
Inventory.AddToList(13,{Name="Phone", Weight=1, Model="models/props/de_prodigy/desk_console1b.mdl", Functions={Inventory.CallMerchant}})
Inventory.AddToList(12,{Name="Bleach", Weight=2, Model="models/props_junk/garbage_plasticbottle001a.mdl", Functions={Inventory.BadDrink}})
Inventory.AddToList(13,{Name="Bleach", Weight=1, Model="models/props_junk/garbage_plasticbottle002a.mdl", Functions={Inventory.BadDrink}})
Inventory.AddToList(16,{Name="Paint", Weight=4, Model="models/props_junk/metal_paintcan001a.mdl", Functions={Inventory.BadDrink}})
Inventory.AddToList(17,{Name="Paint", Weight=4, Model="models/props_junk/metal_paintcan001b.mdl", Functions={Inventory.BadDrink}})
Inventory.AddToList(32,{Name="Paint", Weight=5, Model="models/props/cs_militia/paintbucket01.mdl", Functions={Inventory.BadDrink}})
Inventory.AddToList(18,{Name="Grease", Weight=3, Model="models/props_junk/plasticbucket001a.mdl", Functions={Inventory.BadDrink}})
Inventory.AddToList(22,{Name="Clipboard", Weight=1, Model="models/props_lab/clipboard.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(82,{Name="Murray", Weight=1, Model="models/gibs/hgibs.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(82,{Name="Wrench", Weight=1, Model="models/props_c17/tools_wrench01a.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(82,{Name="Pliers", Weight=1, Model="models/props_c17/tools_pliers01a.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(17,{Name="Rock", Weight=2, Model="models/props_junk/rock001a.mdl", Functions={Inventory.BadEat,Inventory.Throw}})
Inventory.AddToList(27,{Name="Cactus", Weight=1, Model="models/props_lab/cactus.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(82,{Name="Newspaper", Weight=1, Model="models/props_junk/garbage_newspaper001a.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(22,{Name="Journal", Weight=1, Model="models/props_lab/binderblue.mdl", Functions={Inventory.Read}})
Inventory.AddToList(22,{Name="Phonebook", Weight=1, Model="models/props_lab/binderbluelabel.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(82,{Name="Binder", Weight=1, Model="models/props_lab/bindergraylabel01b.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(82,{Name="Binder", Weight=1, Model="models/props_lab/bindergreen.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(82,{Name="Notebook", Weight=1, Model="models/props_lab/bindergreenlabel.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(50,{Name="Garbage", Weight=3, Model="models/props/cs_office/trash_can.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(18,{Name="Dildo", Weight=1, Model="models/gibs/hgibs_spine.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(73,{Name="Dildo", Weight=1, Model="models/props_c17/trappropeller_lever.mdl", Functions={Inventory.BadEat}}) 
Inventory.AddToList(57,{Name="Plant", Weight=2, Model="models/props/de_inferno/potted_plant1.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(18,{Name="Plant", Weight=2, Model="models/props/de_inferno/potted_plant2.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(59,{Name="Plant", Weight=2, Model="models/props/de_inferno/potted_plant3.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(12,{Name="Doll", Weight=1, Model="models/props/de_tides/vending_turtle.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(13,{Name="Paper", Weight=1, Model="models/props_c17/paper01.mdl", Functions={Inventory.BadEat}}) 
Inventory.AddToList(12,{Name="Hat", Weight=1, Model="models/props/de_tides/vending_hat.mdl", Functions={Inventory.BadEat}}) 
Inventory.AddToList(12,{Name="Hat", Weight=1, Model="models/props/cs_office/snowman_hat.mdl", Functions={Inventory.BadEat}})
Inventory.AddToList(51,{Name="Padlock", Weight=1, Model="models/props_wasteland/prison_padlock001a.mdl", Functions={Inventory.BadEat,Inventory.Throw}})
Inventory.AddToList(51,{Name="Padlock", Weight=1, Model="models/props_wasteland/prison_padlock001b.mdl", Functions={Inventory.BadEat,Inventory.Throw}})
Inventory.AddToList(60,{Name="Register", Weight=5, Model="models/props_c17/cashregister01a.mdl", Functions={Inventory.Loot,Inventory.Throw}})
Inventory.AddToList(818,{Name=WOOD, Weight=1, Model="models/props/de_tides/patio_chair.mdl", Functions={}, Barricade=true})
Inventory.AddToList(818,{Name=WOOD, Weight=1, Model="models/props/cs_militia/barstool01.mdl", Functions={}, Barricade=true})
Inventory.AddToList(818,{Name=WOOD, Weight=1, Model="models/props_c17/bench01a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(819,{Name=WOOD, Weight=1, Model="models/props_c17/woodbarrel001.mdl", Functions={}, Barricade=true})
Inventory.AddToList(819,{Name=WOOD, Weight=1, Model="models/props_c17/frame002a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(910,{Name=WOOD, Weight=1, Model="models/props_c17/furniturechair001a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(919,{Name=WOOD, Weight=1, Model="models/props_c17/furnituredrawer001a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(912,{Name=WOOD, Weight=1, Model="models/props_c17/furnituredrawer002a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(913,{Name=WOOD, Weight=1, Model="models/props_c17/furnituredrawer003a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(914,{Name=WOOD, Weight=1, Model="models/props_c17/furnituredresser001a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(915,{Name=WOOD, Weight=1, Model="models/props_c17/furnituretable001a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(916,{Name=WOOD, Weight=1, Model="models/props_c17/furnituretable002a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(917,{Name=WOOD, Weight=1, Model="models/props_c17/furnituretable003a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(918,{Name=WOOD, Weight=1, Model="models/props_c17/shelfunit01a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(919,{Name=WOOD, Weight=1, Model="models/props_interiors/furniture_cabinetdrawer01a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(100,{Name=WOOD, Weight=1, Model="models/props_interiors/furniture_cabinetdrawer02a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(101,{Name=WOOD, Weight=1, Model="models/props_interiors/furniture_chair01a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(102,{Name=WOOD, Weight=1, Model="models/props_interiors/furniture_desk01a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(103,{Name=WOOD, Weight=1, Model="models/props_interiors/furniture_shelf01a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(104,{Name=WOOD, Weight=1, Model="models/props_interiors/furniture_vanity01a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(105,{Name=WOOD, Weight=1, Model="models/props_junk/wood_crate001a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(106,{Name=WOOD, Weight=1, Model="models/props_junk/wood_crate001a_damaged.mdl", Functions={}, Barricade=true})
Inventory.AddToList(107,{Name=WOOD, Weight=1, Model="models/props_junk/wood_crate001a_damagedmax.mdl", Functions={}, Barricade=true})
Inventory.AddToList(108,{Name=WOOD, Weight=1, Model="models/props_junk/wood_crate002a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(109,{Name=WOOD, Weight=1, Model="models/props_junk/wood_pallet001a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(822,{Name=WOOD, Weight=1, Model="models/props_c17/furnitureshelf001b.mdl", Functions={}, Barricade=true})
Inventory.AddToList(103,{Name=WOOD, Weight=1, Model="models/props_wasteland/barricade001a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(103,{Name=WOOD, Weight=1, Model="models/props_wasteland/barricade002a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(103,{Name=WOOD, Weight=1, Model="models/props_wasteland/cafeteria_table001a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(103,{Name=WOOD, Weight=1, Model="models/props_wasteland/cafeteria_bench001a.mdl", Functions={}, Barricade=true})
Inventory.AddToList(103,{Name=WOOD, Weight=1, Model="models/props_c17/door01_left.mdl", Functions={}, Barricade=true})
Inventory.AddToList(103,{Name=WOOD, Weight=1, Model="models/props/de_inferno/tableantique.mdl", Functions={}, Barricade=true})
Inventory.AddToList(103,{Name=WOOD, Weight=1, Model="models/props/de_inferno/tablecoffee.mdl", Functions={}, Barricade=true})
Inventory.AddToList(103,{Name=WOOD, Weight=1, Model="models/props/de_inferno/chairantique.mdl", Functions={}, Barricade=true})
Inventory.AddToList(103,{Name=WOOD, Weight=1, Model="models/props/de_inferno/wine_barrel.mdl", Functions={}, Barricade=true})
Inventory.AddToList(111,{Name=WOODC, Weight=1, Model="models/props_debris/wood_chunk04a.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(112,{Name=WOODC, Weight=1, Model="models/props_debris/wood_chunk06b.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(113,{Name=WOODC, Weight=1, Model="models/props_debris/wood_chunk06a.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(822,{Name="Survival Guide", Weight=0, Model="models/props_lab/binderredlabel.mdl", Functions=3, Points=true})
Inventory.AddToList(112,{Name="Money", Weight=0, Model="models/props/cs_assault/dollar.mdl", Functions=1, Points=true})
Inventory.AddToList(112,{Name="Money", Weight=0, Model="models/props/cs_assault/money.mdl", Functions=2, Points=true})
Inventory.AddToList(110,{Name="Milk Crate", Weight=3, Model="models/props_junk/plasticcrate01a.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(113,{Name="Desk Lamp", Weight=1, Model="models/props_lab/desklamp01.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(112,{Name="Meat Hook", Weight=5, Model="models/props_junk/meathook001a.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(732,{Name="Saw Blade", Weight=6, Model="models/props_junk/sawblade001a.mdl", Functions={Inventory.Throw}}) 
Inventory.AddToList(112,{Name="Extinguisher", Weight=4, Model="models/props/cs_office/fire_extinguisher.mdl", Functions={Inventory.ThrowExt}}) 
Inventory.AddToList(732,{Name="Car Battery", Weight=4, Model="models/items/car_battery01.mdl", Functions={Inventory.Throw}}) 
Inventory.AddToList(732,{Name="Traffic Cone", Weight=5, Model="models/props_junk/trafficcone001a.mdl", Functions={Inventory.Throw}}) 
Inventory.AddToList(732,{Name="Files", Weight=4, Model="models/props/cs_office/file_box.mdl", Functions={Inventory.Throw}}) 
Inventory.AddToList(732,{Name="Globe", Weight=5, Model="models/props_combine/breenglobe.mdl", Functions={Inventory.Throw}}) 
Inventory.AddToList(612,{Name="Keyboard", Weight=1, Model="models/props_c17/computer01_keyboard.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(622,{Name="Computer", Weight=4, Model="models/props_c17/consolebox01a.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(632,{Name="Computer", Weight=4, Model="models/props_c17/consolebox03a.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(624,{Name="Computer", Weight=4, Model="models/props_c17/consolebox05a.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(626,{Name="Television", Weight=4, Model="models/props_c17/tv_monitor01.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(627,{Name="Brick", Weight=3, Model="models/props_junk/cinderblock01a.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(726,{Name="Bucket", Weight=3, Model="models/props_junk/metalbucket01a.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(727,{Name="Pottery", Weight=2, Model="models/props_junk/terracotta01.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(728,{Name="Computer", Weight=3, Model="models/props_lab/harddrive01.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(729,{Name="Computer", Weight=2, Model="models/props_lab/harddrive02.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(820,{Name="Monitor", Weight=6, Model="models/props_lab/monitor01a.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(821,{Name="Monitor", Weight=5, Model="models/props_lab/monitor01b.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(822,{Name="Monitor", Weight=6, Model="models/props_lab/monitor02.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(823,{Name="Console", Weight=4, Model="models/props_lab/reciever01a.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(824,{Name="Console", Weight=3, Model="models/props_lab/reciever01b.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(825,{Name="Console", Weight=2, Model="models/props_lab/reciever01c.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(826,{Name="Console", Weight=2, Model="models/props_lab/reciever01d.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(824,{Name="Gear", Weight=4, Model="models/props_wasteland/gear01.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(824,{Name="Gear", Weight=4, Model="models/props_wasteland/gear02.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(827,{Name="Old Lamp", Weight=2, Model="models/props_c17/lamp001a.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(511,{Name="Plasma TV", Weight=7, Model="models/props/cs_office/tv_plasma.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(513,{Name="Computer", Weight=3, Model="models/props/cs_office/computer_case.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(514,{Name="Keyboard", Weight=1, Model="models/props/cs_office/computer_keyboard.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(515,{Name="Monitor", Weight=4, Model="models/props/cs_office/computer_monitor.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(516,{Name="Microwave", Weight=5, Model="models/props/cs_office/microwave.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(614,{Name="Console", Weight=1, Model="models/props_lab/reciever01a.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(614,{Name="Console", Weight=1, Model="models/props_lab/reciever01b.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(614,{Name="Toolbox", Weight=4, Model="models/props_lab/partsbin01.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(311,{Name="Toilet", Weight=5, Model="models/props_wasteland/prison_toilet01.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(417,{Name="Projector", Weight=3, Model="models/props/cs_office/projector.mdl", Functions={Inventory.Throw}})
Inventory.AddToList(418,{Name="Radio", Weight=1, Model="models/props/cs_office/radio.mdl", Functions={Inventory.Throw}})

function Inventory.UpdateClientStock(ply)
	for k,v in pairs(Inventory.Merchant) do
		umsg.Start("ReduceStock", ply)
		umsg.String(v.Name)
		umsg.Short(v.Stock)
		umsg.End() 
	end
end

function Inventory.ReduceStock(name)
	for k,v in pairs(Inventory.Merchant) do
		if v.Name == name then
			Inventory.Merchant[k].Stock = math.Clamp(v.Stock - 1,0,100)
			for c,d in pairs(player.GetAll()) do
				umsg.Start("ReduceStock", d)
				umsg.String(name)
				umsg.Short(Inventory.Merchant[k].Stock)
				umsg.End() 
			end
		end
	end
end

Inventory.Merchant = {}
GameInfo.GunStock = 5
function Inventory.MerchantAdd(obsolete,tbl)
	local num = table.Count(Inventory.Merchant) + 1
	//tbl.Stock = tbl.Stock or GameInfo.GunStock
	Inventory.Merchant[num] = tbl
end

Inventory.MerchantAdd(113,{Name="Dual Berettas", Model="models/weapons/w_pist_elite_dropped.mdl", Price=15, Weapon="weapon_berettas_tp", Stock=GameInfo.GunStock,
Desc="What these guns lack in quality they make up for in quantity."})

Inventory.MerchantAdd(113,{Name="Desert Eagle", Model="models/weapons/w_pist_deagle.mdl", Price=20, Weapon="weapon_deagle_tp", Stock=GameInfo.GunStock,
Desc="The best pistol available. Consider it your life insurance."})

Inventory.MerchantAdd(113,{Name="TMP", Model="models/weapons/w_smg_tmp.mdl", Price=25, Weapon="weapon_tmp_sg", Stock=GameInfo.GunStock,
Desc="A silent but deadly machine pistol. Useful for stealth operations."})

Inventory.MerchantAdd(113,{Name="MAC-10", Model="models/weapons/w_smg_mac10.mdl", Price=30, Weapon="weapon_mac10_sg", Stock=GameInfo.GunStock,
Desc="This submachine gun has a lot of kick, but deals some serious damage."})

Inventory.MerchantAdd(113,{Name="HK-UMP45", Model="models/weapons/w_smg_ump45.mdl", Price=35, Weapon="weapon_ump45_sg", Stock=GameInfo.GunStock,
Desc="A deadly submachine gun with a slightly smaller clip. Size isn't everything."})

Inventory.MerchantAdd(113,{Name="HK-MP5", Model="models/weapons/w_smg_mp5.mdl", Price=40, Weapon="weapon_hkmp5_sg", Stock=GameInfo.GunStock,
Desc="This reliable military submachine gun is perfect for zombie hunting."})

Inventory.MerchantAdd(113,{Name="Winchester", Model="models/weapons/w_annabelle.mdl", Price=45, Weapon="weapon_winchester_sh", Stock=GameInfo.GunStock,
Desc="You can kill zombies in style with this badass lever-action shotgun."})

Inventory.MerchantAdd(113,{Name="FN-P90", Model="models/weapons/w_smg_p90.mdl", Price=50, Weapon="weapon_p90_sg", Stock=GameInfo.GunStock,
Desc="This submachine gun has a large magazine that holds 50 rounds."})

Inventory.MerchantAdd(113,{Name="Remington 700", Model="models/weapons/w_snip_scout.mdl", Price=55, Weapon="weapon_remington_sh", Stock=GameInfo.GunStock,
Desc="A hunting rifle that's effective against deer. Too bad it's zombie season."})

Inventory.MerchantAdd(113,{Name="IMI Galil", Model="models/weapons/w_rif_galil.mdl", Price=60, Weapon="weapon_galil_ar", Stock=GameInfo.GunStock,
Desc="This slightly inaccurate machine gun has a larger magazine."})

Inventory.MerchantAdd(113,{Name="FAMAS F1", Model="models/weapons/w_rif_famas.mdl", Price=65, Weapon="weapon_famas_ar", Stock=GameInfo.GunStock,
Desc="A decent machine gun with a smaller magazine. Blame the french."})

Inventory.MerchantAdd(113,{Name="Ruger 77", Model="models/weapons/w_shot_xm1014.mdl", Price=70, Weapon="weapon_ruger77_sh", Stock=GameInfo.GunStock,
Desc="This dangerous rifle holds 4 high caliber bullets."})

Inventory.MerchantAdd(113,{Name="AK-47", Model="models/weapons/w_rif_ak47.mdl", Price=75, Weapon="weapon_ak47_ar", Stock=GameInfo.GunStock,
Desc="This accurate and powerful assault rifle will make short work of zombies."})

Inventory.MerchantAdd(113,{Name="SPAS-12", Model="models/weapons/w_shotgun.mdl", Price=80, Weapon="weapon_spas12_sh", Stock=GameInfo.GunStock,
Desc="This powerful military shotgun is very useful for crowd control."})

Inventory.MerchantAdd(113,{Name="Steyr AUG", Model="models/weapons/w_rif_aug.mdl", Price=85, Weapon="weapon_steyr_ar", Stock=GameInfo.GunStock,
Desc="A military machine gun with a scope for precision shooting."})

Inventory.MerchantAdd(113,{Name="AW-50", Model="models/weapons/w_snip_awp.mdl", Price=90, Weapon="weapon_aw50_sh", Stock=GameInfo.GunStock,
Desc="This military sniper rifle fires a .50 calibre bullet. "})

Inventory.MerchantAdd(113,{Name="SIG SG-550", Model="models/weapons/w_snip_sg550.mdl", Price=95, Weapon="weapon_sg550_ar", Stock=GameInfo.GunStock,
Desc="An automatic sniper rifle with a 20-round magazine."})

Inventory.MerchantAdd(113,{Name="M249 SAW", Model="models/weapons/w_mach_m249para.mdl", Price=100, Weapon="weapon_m249_ar", Stock=GameInfo.GunStock,
Desc="Your patience will be rewarded with raw firepower."})

Inventory.MerchantAdd(113,{Name="Flamethrower", Model="models/weapons/w_rocket_launcher.mdl", Price=200, Weapon="weapon_flamethrower_n", Stock=1,
Desc="I once heard that burnt zombies taste like chicken."})

//ammo
Inventory.MerchantAdd(113,{Name="Pistol Rounds", Model="models/Items/357ammobox.mdl", Price=10, Weight=40, Ammo="pistol", Stock=50,
Desc="40 standard rounds used in all semi-automatic pistol variants."})
Inventory.MerchantAdd(113,{Name="SMG Rounds", Model="models/Items/BoxSRounds.mdl", Price=10, Weight=60, Ammo="smg1", Stock=50,
Desc="60 standard rounds used in all submachine guns."})
Inventory.MerchantAdd(113,{Name="Buckshot", Model="models/Items/BoxBuckshot.mdl", Price=10, Weight=12, Ammo="buckshot", Stock=50,
Desc="12 standard rounds used in all shotguns and non-automatic rifles."})
Inventory.MerchantAdd(113,{Name="Rifle Rounds", Model="models/Items/BoxMRounds.mdl", Price=10, Weight=30, Ammo="ar2", Stock=50,
Desc="30 standard rounds used in all automatic rifles and machine guns."})

//items
Inventory.MerchantAdd(112,{Name="Mystery Item", Model="models/props_c17/briefcase001a.mdl", Price=5, Weight=1, Stock=10,
Desc="I wonder what it could be..."})
Inventory.MerchantAdd(113,{Name=AID, Model="models/props_junk/cardboard_box004a.mdl", Price=10, Weight=1, Stock=5,
Desc="Heals 10 HP and stops all bleeding."})
Inventory.MerchantAdd(112,{Name="Molotov", Model="models/props/cs_militia/bottle02.mdl", Price=15, Weight=1, Stock=5,
Desc="Bottle full of gasoline that explodes when thrown."})
Inventory.MerchantAdd(115,{Name="Antidote", Model="models/items/battery.mdl", Price=20, Weight=1, Stock=5,
Desc="Neutralizes all toxins and partially restores stamina."})
Inventory.MerchantAdd(112,{Name="Health Vial", Model="models/healthvial.mdl", Price=25, Weight=1, Stock=5,
Desc="Heals 25 HP and fully restores stamina."})
Inventory.MerchantAdd(112,{Name="Respirator", Model="models/items/combine_rifle_cartridge01.mdl", Price=30, Weight=1, Stock=5,
Desc="Gives the owner immunity to radiation poisoning."})

function Inventory.FindWeaponTable(model)
	local merch = table.Copy(Inventory.Merchant)
	merch[table.Count(merch)+1] = {Name="SIG P228", Model="models/weapons/w_pist_p228.mdl", Weapon="weapon_p228_tp"}
	merch[table.Count(merch)+1] = {Name="Glock 22", Model="models/weapons/w_pist_glock18.mdl", Weapon="weapon_glock22_tp"}
	merch[table.Count(merch)+1] = {Name="FN Five-Seven", Model="models/weapons/w_pist_fiveseven.mdl", Weapon="weapon_fiveseven_tp"}
	merch[table.Count(merch)+1] = {Name="USP Compact", Model="models/weapons/w_pistol.mdl", Weapon="weapon_usp_tp"}
	merch[table.Count(merch)+1] = {Name="Antidote", Model="models/items/combine_rifle_ammo01.mdl", Weapon="lolcake"}
	for k,v in pairs(merch) do
		if v.Model == model then
			return v
		end
	end
	return nil
end